﻿using GrainManage.Entities.Image;
using GrainManage.Server.Business;
using System.Web.Mvc;

namespace GrainManage.Server.Controllers
{
    public class ImageController : BaseController
    {
        private readonly ImageBusiness business = new ImageBusiness();

        //************************************************POST************************************************

        [HttpPost]
        public ActionResult GetImages(InputGetImages input)
        {
            var result = business.GetImages(input);
            return NewtonsoftJson(result);
        }

        [HttpPost]
        public ActionResult GetImageFile(InputGetImageFile input)
        {
            var result = business.GetImageFile(input);
            return NewtonsoftJson(result);
        }

        [HttpPost]
        public ActionResult GetImageUrl(InputGetImageUrl input)
        {
            var result = business.GetImageUrl(input);
            return NewtonsoftJson(result);
        }

        [HttpPost]
        public ActionResult Download(InputDownLoad input)
        {
            var result = business.DownLoad(input);
            return File(result, "image/jpeg");
        }

        [HttpPost]
        public ActionResult Insert(InputInsert input)
        {
            var result = business.Insert(input);
            return NewtonsoftJson(result);
        }

        [HttpPost]
        public ActionResult Update(InputUpdate input)
        {
            var result = business.Update(input);
            return NewtonsoftJson(result);
        }

        [HttpPost]
        public ActionResult Delete(InputDelete input)
        {
            var result = business.Delete(input);
            return NewtonsoftJson(result);
        }

        //[HttpPost]
        //public string BatchInsert(InputBatchInsert input)
        //{
        //    var result = business.BatchInsert(input);
        //    return Json(result);
        //}

        //[HttpPost]
        //public string BatchUpdate(InputBatchUpdate input)
        //{
        //    var result = business.BatchUpdate(input);
        //    return Json(result);
        //}

        //[HttpPost]
        //public string BatchDelete(InputBatchDelete input)
        //{
        //    var result = business.BatchDelete(input);
        //    return Json(result);
        //}
    }
}
